#ifndef _SYS_UART_H_
#define _SYS_UART_H_

#include "stm32f1_basic_func.h"
#include "app.h"

#define USART_REC_LEN  			200
typedef enum _baudrate
{
    baudrate_9600 = 9600,
    baudrate_115200 = 115200,
}SYS_BAUDRATE;

typedef struct _sys_uart
{
    /* data */
    SYS_BAUDRATE baudrate;
    BOOL         dbg_flag;
}SYS_UART_S;

#define SYS_USMART_GPIO_PeriphClockFunc     RCC_APB2PeriphClockCmd
#define SYS_USMART_GPIO_PeriphClock         RCC_APB2Periph_GPIOA
#define SYS_USMART_GPIO_PORT                GPIOA
#define SYS_USMART_GPIO_TXD                 GPIO_Pin_2
#define SYS_USMART_GPIO_TXD_AF              GPIO_PinSource2
#define SYS_USMART_GPIO_RXD                 GPIO_Pin_3
#define SYS_USMART_GPIO_RXD_AF              GPIO_PinSource3

#define SYS_USMART_PeriphClockFunc          RCC_APB1PeriphClockCmd//RCC_APB2PeriphClockCmd
#define SYS_USMART_PeriphClock              RCC_APB1Periph_USART2//RCC_APB2Periph_USART1
#define SYS_USMART_USARTx                   USART2//USART1
#define SYS_USMART_USARTx_IRQ               USART2_IRQn//USART1_IRQn
#define SYS_USMART_USARTx_IRQ_Handler       USART2_IRQHandler//USART1_IRQHandler

#define CHKFILE                 printf("CHKFILE: %d\t%s\r\n",__LINE__,__FILE__)
#define CHKPNT                  printf("\nCHK:func:%s Line:%d\r\n",__FUNCTION__,__LINE__)
#define DBG_MSG(fmt,arg...)     printf(""fmt"",##arg)
#define DBG_ERR(fmt,arg...)     printf("ERR:"fmt"",##arg)
#define DBG_INFO(fmt,arg...)    printf(" %s() "fmt"",__FUNCTION__,##arg)

extern SYS_UART_S  sys_uart_sturct;


void sys_uart_init(SYS_BAUDRATE boundrate);
uint8_t sys_usmart_getstring(uint8_t *rx_str);

#endif
